package com.TIEmulator;

import android.view.KeyEvent;
import com.TIEmulator.JNI.NLib;

public class KeyListener
{
  private final ModifierKey mAltKey = new ModifierKey();
  private final ModifierKey mControlKey = new ModifierKey();

  private int[] DPadResult(int paramInt)
  {
    int[] arrayOfInt = new int[3];
    arrayOfInt[0] = paramInt;
    arrayOfInt[1] = 0;
    this.mAltKey.adjustAfterKeypress();
    this.mControlKey.adjustAfterKeypress();
    return arrayOfInt;
  }

  public void handleControlKey(boolean paramBoolean)
  {
    if (paramBoolean)
      this.mControlKey.onPress();
    while (true)
    {
      return;
      this.mControlKey.onRelease();
    }
  }

  public int[] keyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    Object localObject = null;
    int[] arrayOfInt;
    int j;
    label133: label143: int i;
    switch (paramInt)
    {
    default:
      arrayOfInt = new int[3];
      arrayOfInt[1] = 0;
      switch (paramInt)
      {
      default:
        if (!(this.mAltKey.isActive()))
          break label281;
        j = 2;
        arrayOfInt[0] = paramKeyEvent.getUnicodeChar(j);
        i = arrayOfInt[0];
        if (!(this.mControlKey.isActive()))
          break label417;
        if ((i < 97) || (i > 122))
          break label287;
        arrayOfInt[0] = (char)(1 + i - 97);
        label185: if (arrayOfInt[0] <= -1)
          break label553;
        this.mAltKey.adjustAfterKeypress();
        this.mControlKey.adjustAfterKeypress();
      case 67:
      }
    case 19:
    case 20:
    case 21:
    case 22:
    case 23:
    case 57:
    case 58:
    case 59:
    case 60:
    case 66:
    }
    while (true)
    {
      localObject = arrayOfInt;
      while (true)
      {
        return localObject;
        localObject = DPadResult(13);
        continue;
        this.mAltKey.onPress();
        continue;
        NLib.postTIKeyCodeIdx(OnScreenKeys.SHIFT_KC);
        continue;
        NLib.postTIKeyCodeIdx(OnScreenKeys.ENTER_KC);
      }
      if (this.mAltKey.isActive())
        arrayOfInt[0] = 127;
      arrayOfInt[0] = 8;
      break label143:
      label281: j = 0;
      break label133:
      if (i == 32)
        label287: arrayOfInt[0] = 0;
      if ((i == 91) || (i == 49))
        arrayOfInt[0] = 27;
      if ((i == 92) || (i == 46))
        arrayOfInt[0] = 28;
      if ((i == 93) || (i == 48))
        arrayOfInt[0] = 29;
      if ((i == 94) || (i == 54))
        arrayOfInt[0] = 30;
      if ((i == 95) || (i == 53));
      arrayOfInt[0] = 31;
      break label185:
      label417: if (this.mAltKey.isActive());
      switch (i)
      {
      default:
        break;
      case 33:
        arrayOfInt[0] = 119;
        arrayOfInt[1] = 2;
        break;
      case 123:
        arrayOfInt[0] = 40;
        arrayOfInt[1] = 2;
        break;
      case 125:
        arrayOfInt[0] = 41;
        arrayOfInt[1] = 2;
        break;
      case 91:
        arrayOfInt[0] = 44;
        arrayOfInt[1] = 2;
        break;
      case 93:
      }
      arrayOfInt[0] = 47;
      arrayOfInt[1] = 2;
      break label185:
      label553: arrayOfInt = (int[])localObject;
    }
  }

  public void keyUp(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 57:
    case 58:
    }
    while (true)
    {
      return;
      this.mAltKey.onRelease();
    }
  }
}

